home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7307 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: arc-tac2-slip10.nsi.nasa.gov!rjtanner
  2. From: rjtanner@netcom.com (Rob Tanner)
  3. Newsgroups: comp.lang.c
  4. Subject: Q: How can I figure out the full path to myself! (UNIX)
  5. Followup-To: comp.lang.c
  6. Date: Mon, 19 Feb 96 00:53:48 GMT
  7. Organization: NAS/NASA Ames Research Center
  8. Message-ID: <rjtanner.1175078868A@cnn.nas.nasa.gov>
  9. NNTP-Posting-Host: arc-tac2-slip10.nsi.nasa.gov
  10. X-Newsreader: VersaTerm Link v1.1.5
  11.  
  12.  
  13. I am writing a "C" wrapper that will be used to accumulate statistics on 
  14. the 100's of MB of public domain code my group maintains for the Center.
  15. Basically, when someone wants to execute one of the wrapped programs, what
  16. they really get is the wrapper which does some accounting kind of things
  17. (most people execute the programs were measuring from an NFS mounted 
  18. filesystem) and then exec's the real executable which is stored one directory
  19. level beneath the wrapper.
  20.  
  21. In order to be able to find the real executable, I always need to know the
  22. real absolute path to the wrapper, and since I have no control over all those
  23. other machines, that path can vary from machine to machine.  In most cases
  24. that's not a problem since I can chase down the path from the information 
  25. contained in argv[0].
  26.  
  27. However, there are some exceptions.  Login, for example, gets the path from 
  28. login entry in /etc/passwd, but invokes the shell with only the name of the 
  29. shell in argv[0], thus all the info I might get would be "tcsh" (or "-tcsh).
  30. Normally, I could chase down a user's path and find the execution instance, 
  31. but during a login process there isn't sufficient path information in the
  32. environment to locate where I am executing from.  Moreover, any process can
  33. exec another without providing sufficient path info in argv[0].
  34.  
  35. Are there any tricks reading system/proc tables that someone could suggest?
  36. I'll need to port the wrappers to SunOS4, SunOS5, IRIX4, IRIX5, and IRIX6,
  37. so I hope there's a trick or tricks I can use for each of the platforms.
  38.  
  39. Thanks,
  40. Rob Tanner
  41.       _ _ _ _           _    _ _ _ _ _    
  42.      /\_\_\_\_\        /\_\ /\_\_\_\_\_\  
  43.     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
  44.    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
  45.   /\/_/_/_/_/ /\_\  /\/_/    /\/_/             
  46.  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  47.  \/_/  \/_/  \/_/_/_/_/     \/_/              sounds profound)
  48.  
  49.  Rob Tanner
  50.  rjtanner@netcom.com
  51.  _____________________________________________________________________
  52.